#-------------------------------------------------------
# Copyright (c) YY
# All rights reserved.
# History:
# 		<Author>	<Time>		<Version>	  <Des>
#      guoyou		2017-9-4	1.0		
#-------------------------------------------------------
cmake_minimum_required(VERSION 2.8)

project(DMWeb)  
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)

#-------------------------------------------------------------------------------------------------------------------
set(PROJDIR ${CMAKE_CURRENT_SOURCE_DIR})

#-------------------------------------------------------------------------------------------------------------------
set(EXECUTABLE_OUTPUT_PATH ${DMWeb_BINARY_DIR}/bin)
set(LIBRARY_OUTPUT_PATH  ${DMWeb_BINARY_DIR}/bin)

set(LIBS ${LIBRARY_OUTPUT_PATH})
link_directories(${LIBS})
#-------------------------------------------------------------------------------------------------------------------
option(USE_DMDLL_ "Compile DMMain as dll"   ON) 
if(USE_DMDLL_)
	add_definitions(-DDLL_DMMAIN)
endif()
option(USE_DMLOG_  "DM open log"    ON)
if(USE_DMLOG_)
	add_definitions(-DDMLOG_ON)
endif()

#-------------------------------------------------------------------------------------------------------------------
# 定义是使用3rdParty/cef_xxxx做为目录，默认cef_2326
set(CEF_VERSION "2623" CACHE STRING "CEF version")
set(CEF_BINARY_DIR ""  CACHE STRING "CEF二进制目录，如果空，则使用 cef_<CEF_VERSION> 作为二进制目录")

# 支持外部设置CEF路径
set(CEF_ROOT "${CEF_BINARY_DIR}")
if (CEF_ROOT STREQUAL "")
	set(CEF_IS_EXTERNAL false)
	set(CEF_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/3rdParty/cef_${CEF_VERSION}")
else()
	set(CEF_IS_EXTERNAL true)
	set(CEF_VERSION "2623") # 使用外部CEF库时默认版本为2623
endif()

if (NOT IS_DIRECTORY ${CEF_ROOT})
	message(FATAL_ERROR "CEF_VERSION(${CEF_VERSION}) not exist. Check dir('${CEF_ROOT}').")
endif()
add_definitions(-DCEF_CURRENT_VERSION=${CEF_VERSION})#指定CEF_CURRENT_VERSION宏

#-------------------------------------------------------------------------------------------------------------------
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMake)
include(PrecompiledHeader)

#-------------------------------------------------------------------------------------------------------------------
if (CEF_IS_EXTERNAL)
	add_subdirectory(${CEF_ROOT} DMWeb/cef_external)
else()
	add_subdirectory(${CEF_ROOT})
endif()
add_subdirectory(${PROJDIR}/DMMain)
add_subdirectory(${PROJDIR}/3rdParty/cef_module)
add_subdirectory(${PROJDIR}/3rdParty/cef_render)
add_subdirectory(${PROJDIR}/DMWebTest)
add_subdirectory(${PROJDIR}/PluginWeb)
